﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="detailandmed_v5_sundlopetamine", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(DetailandmedV5Sundlopetamine))]
    public class DetailandmedV5SundlopetamineSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IDetailandmedV5Sundlopetamine clazz;
        
        public DetailandmedV5SundlopetamineSerializer(IDetailandmedV5Sundlopetamine clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Alus!=null) {
                Writer.WriteStartElement("alus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Alus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlusTekstina!=null) {
                Writer.WriteStartElement("alus_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AlusTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Alajaotus!=null) {
                Writer.WriteStartElement("alajaotus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Alajaotus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlajaotusTekstina!=null) {
                Writer.WriteStartElement("alajaotus_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AlajaotusTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlajaotuseKpv!=null) {
                Writer.WriteStartElement("alajaotuse_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.AlajaotuseKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Teade!=null) {
                Writer.WriteStartElement("teade");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Teade))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TeateKpv!=null) {
                Writer.WriteStartElement("teate_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.TeateKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TeateAvaldajaRegistriosakond!=null) {
                Writer.WriteStartElement("teate_avaldaja_registriosakond");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.TeateAvaldajaRegistriosakond))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TeateAvaldajaRegistriosakondTekstina!=null) {
                Writer.WriteStartElement("teate_avaldaja_registriosakond_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.TeateAvaldajaRegistriosakondTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AsukohajargneKohus!=null) {
                Writer.WriteStartElement("asukohajargne_kohus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.AsukohajargneKohus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AsukohajargneKohusTekstina!=null) {
                Writer.WriteStartElement("asukohajargne_kohus_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AsukohajargneKohusTekstina))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="alus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_sundlopetamine>alus");
                }
                clazz.Alus = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("alus")).Value;
            }
            if (Reader.LocalName=="alus_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_sundlopetamine>alus_tekstina");
                }
                clazz.AlusTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("alus_tekstina")).Value;
            }
            if (Reader.LocalName=="alajaotus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_sundlopetamine>alajaotus");
                }
                clazz.Alajaotus = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("alajaotus")).Value;
            }
            if (Reader.LocalName=="alajaotus_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_sundlopetamine>alajaotus_tekstina");
                }
                clazz.AlajaotusTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("alajaotus_tekstina")).Value;
            }
            if (Reader.LocalName=="alajaotuse_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_sundlopetamine>alajaotuse_kpv");
                }
                clazz.AlajaotuseKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("alajaotuse_kpv")).Value;
            }
            if (Reader.LocalName=="teade") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_sundlopetamine>teade");
                }
                clazz.Teade = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("teade")).Value;
            }
            if (Reader.LocalName=="teate_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_sundlopetamine>teate_kpv");
                }
                clazz.TeateKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("teate_kpv")).Value;
            }
            if (Reader.LocalName=="teate_avaldaja_registriosakond") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_sundlopetamine>teate_avaldaja_registriosakond");
                }
                clazz.TeateAvaldajaRegistriosakond = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("teate_avaldaja_registriosakond")).Value;
            }
            if (Reader.LocalName=="teate_avaldaja_registriosakond_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_sundlopetamine>teate_avaldaja_registriosakond_tekstina");
                }
                clazz.TeateAvaldajaRegistriosakondTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("teate_avaldaja_registriosakond_tekstina")).Value;
            }
            if (Reader.LocalName=="asukohajargne_kohus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_sundlopetamine>asukohajargne_kohus");
                }
                clazz.AsukohajargneKohus = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("asukohajargne_kohus")).Value;
            }
            if (Reader.LocalName=="asukohajargne_kohus_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_v5_sundlopetamine>asukohajargne_kohus_tekstina");
                }
                clazz.AsukohajargneKohusTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("asukohajargne_kohus_tekstina")).Value;
            }
        }
    }
}
